package com.baor.security;

import com.baor.base.domain.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.ReactiveUserDetailsService;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;

@Service
public class UserDetailServiceImpl implements ReactiveUserDetailsService {
    @Autowired
    private PasswordEncoder passwordEncoder;

    @Override
    public Mono<UserDetails> findByUsername(String username) {
        System.out.println("username:"+username);
        LoginUser loginUser = new LoginUser();
        UserVO userVO = new UserVO();
        userVO.setUserId(1);
        userVO.setUserName("admin");
        userVO.setUserPassword(passwordEncoder.encode("123456"));
        loginUser.setUserVO(userVO);
        return Mono.just(loginUser);
    }
}
